﻿using B.S.AuthCenter.Api.Write.Application.Command.Menu;
using B.S.AuthCenter.Api.Write.Application.Command.RoleMenu;
using B.S.AuthCenter.ErrorCount;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.AuthCenter.Api.Write.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class MenusController : ControllerBase
    {
        IMediator mediator;

        public MenusController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        [HttpPost]
        public Task<ApiResult<int>> AddMenu(AddMenuCommand request)
        {
            return mediator.Send(request);
        }
        [HttpPut]
        public Task<ApiResult<int>> UpdateMenu(UpdateMenuCommand request)
        {
            return mediator.Send(request);
        }
        [HttpPut]
        public Task<ApiResult<int>> DelMenu(DeleteMenuCommand request)
        {
            return mediator.Send(request);
        }
        [HttpPost]
        public  Task<ApiResult<int>> AddRoleMenu(AddRoleMenuCommand request)
        {
            return  mediator.Send(request);
        }
    }
}
